import random

def play_game():
    choices = ["剪刀", "石头", "布"]
    
    while True:
        print("\n请选择: 剪刀(1) 石头(2) 布(3) 退出(0)")
        player_choice = input("你的选择是: ")
        
        if player_choice == "0":
            print("谢谢参与,再见!")
            break
        
        if player_choice not in ["1", "2", "3"]:
            print("无效的选择,请重试。")
            continue
        
        player_choice = int(player_choice) - 1
        computer_choice = random.randint(0, 2)
        
        print(f"你选择了: {choices[player_choice]}")
        print(f"电脑选择了: {choices[computer_choice]}")
        
        if player_choice == computer_choice:
            print("平局!")
        elif (player_choice == 0 and computer_choice == 2) or \
             (player_choice == 1 and computer_choice == 0) or \
             (player_choice == 2 and computer_choice == 1):
            print("你赢了!")
        else:
            print("电脑赢了!")

if __name__ == "__main__":
    play_game()